/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 * Tablas
 */
package megaboletosclient;

import clases.*;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Miguel
 */
public class TablaEventoAdmin extends AbstractTableModel{
	private static final long serialVersionUID = 1L;
	String[][] valore;
	private  String[] nombres = {"Clave","Eventos","Fecha","Ciudad"};
	Evento [] evento;
	
	public TablaEventoAdmin(){
	
	}
	
	public TablaEventoAdmin(Evento [] evento){
		this.evento=evento;
		try
			{
				int filas = evento.length;
				valore = new String[filas][4];
				int i =0;
				for(i=0; i<filas; i++)
					{
						valore[i][0]= ""+evento[i].getClave();
						valore[i][1]= ""+evento[i].getNombre();
						valore[i][2]= ""+evento[i].getFecha().toString();
						valore[i][3]= ""+evento[i].getCiudad();
					}
			}
		catch(ArrayIndexOutOfBoundsException e)
			{
				valore = new String[1][5];
			}	
		
	}
		
	public Evento[] getArray()
	{
		return evento;
	}
	public int getRowCount() {
        return valore.length;
    }

    public int getColumnCount() {

        return valore[0].length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        return valore[rowIndex][columnIndex];
    }
    @Override
    public String getColumnName(int columnIndex){
        return nombres[columnIndex];

    }
}